<#assign base=springMacroRequestContext.contextPath>
<#if Session["mobile"]!??>
    <#assign mobile=Session["mobile"]>
</#if>
<!DOCTYPE html>
<html lang="en">
<head>
    <script type="text/javascript" src="${base}/static/js/jquery-1.9.1.min.js"></script>
</head>



<body>
Welcome:<#if mobile!??>${mobile}</#if>
<br>
Date:
    <#if date?exists>
        ${date?string("yyyy-MM-dd HH:mm:ss")}
    </#if>
<br>
Message: ${message?if_exists}
<br>
Code : ${code?if_exists}
<br>
CodeList :<br>
    <#if codeList?exists>
        <#if codeList!??>
            <#list codeList as list>
                ${list.id}&nbsp;&nbsp;${list.receiveEmail}&nbsp;&nbsp;${list.code}&nbsp;&nbsp;${list.addtime}<br>
            </#list>
        </#if>
    </#if>

<br>
<button type="button" onclick="loginOut();">退出</button>
<br>
<br>
<form action="${base}/test1/529330509@qq.com/" method="post">
    <button type="submit">restful1</button>
</form>
<br>
<button type="button" onclick="testRestful2();">restful2</button>
<br>
<br>
<button type="button" onclick="insertEmail();">新增email</button>
<button type="button" onclick="deleteEmail();">删除email</button>
<button type="button" onclick="updateEmail();">更新email</button>
<button type="button" onclick="selectEmail();">查询email</button>

<br>
<br>
<button type="button" onclick="testAliPay();">测试支付宝</button>
<br>
<br>
<input type="checkbox" id="box" onclick="testCheckBox();">测试
<br>
<a href="${base}/toSelect2Page">select2</a>
<br>
<a href="${base}/toElementPage">element</a>
<br>
<#--<button type="button" onclick="testConfirm();">测试confirm</button>-->
<a href="javascript:void (0);" onclick="return false" class="test_click">测试confirm</a>
</body>
<script type="text/javascript">
    function loginOut() {
        window.location.href="${base}/loginOut";
    }

    function testRestful2() {
        $.ajax({
            url : '${base}/test2/WuRui/15140230115',
            type : 'post',
            dataType : 'json',
            success : function (data) {
                alert(data.name+'    '+data.mobile);
            },
            error : function () {
                alert("错误!");
            }
        })
    }

    function insertEmail() {
        $.ajax({
            url : '${base}/email',
            type : 'POST',
            data : {
                receiveEmail : '544431481@qq.com',
                code : '123456'
            },
            dataType : 'json',
            success : function (data) {
                alert(data.resultCode);
            },
            error : function () {
                alert("错误!")
            }
        })
    }

    function deleteEmail() {
        $.ajax({
            url : '${base}/email',
            type : 'POST',
            data : {
                _method : 'DELETE',
                id : 5
            },
            dataType : 'json',
            success : function (data) {
                alert(data.resultCode);
            },
            error : function () {
                alert("错误!")
            }
        })
    }

    function updateEmail() {
        $.ajax({
            url : '${base}/email',
            type : 'POST',
            data : {
                _method : 'PUT',
                id : 4,
                code : '147258'
            },
            dataType : 'json',
            success : function (data) {
                alert(data.resultCode);
            },
            error : function () {
                alert("错误!")
            }
        })
    }

    function selectEmail() {
        $.ajax({
            url : '${base}/email',
            type : 'GET',
            data : {
                receiveEmail : '529330509@qq.com'
            },
            dataType : 'json',
            success : function (data) {
                alert(data.resultCode);
            },
            error : function () {
                alert("错误!")
            }
        })
    }

    function testAliPay() {
        window.location.href = "${base}/alipay";
    }

    function testCheckBox() {
        var flag = document.getElementById("box");
        if(flag.checked == true){
            alert(1);
        }else{
            alert(4);
        }
    }
    
    function testConfirm() {
        if(confirm("确定？")){
            alert(1);
        }
    }

    $(".test_click").click(function () {
        if(confirm("确定？")){
            alert(1);
        }
    })
</script>
</html>